
import GameWorld, { Group } from "./battle/GameWorld";
import Unit from "./battle/Unit";
import  { UnitStateEnum } from "./battle/UnitStateMachine";
import{GroupConfig} from "./config/groupConfig"
const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Node)
    map: cc.Node = null;

    units: Unit[] = [];
    units1: Unit[] = [];
    isstart = false;
    world: GameWorld
    async start() {

        this.world = GameWorld.create(GroupConfig[1],GroupConfig[2],this.map);
        console.log(this.world);
        
        this.world.allUnits.forEach((unit)=>{
            unit.changeState(UnitStateEnum.FindAim);
        });
        this.isstart = true;

    }

    update(dt) {
        if (!this.isstart) {
            return;
        }
        this.world.update(dt);
    }
}
